#include<head.h>

int smg = 20;

void * func_1(void * arg)
{
    while(1)
    {
        smg--;
        sleep(1);
        if(smg == 0)
        {
            pthread_exit(NULL);
        }
    }

}

void * func_2(void * arg)
{
    int my_smg = smg;
    while(1)
    {
        if(my_smg != smg)
        {
            printf("my_smg = %d\n", my_smg);
            my_smg = smg;
        }
        
    }
}

int main(int argc, char const *argv[])
{
    pthread_t tid1, tid2;
    pthread_create(&tid1, NULL, func_1, NULL);
    pthread_create(&tid2, NULL, func_2, NULL);

    pthread_join(tid1, NULL);
    pthread_join(tid2, NULL);
    return 0;
}
